<template>
  <div class="first-app">
    {{msg}}
    <Confirm xl="注册用户" @message="getMessage"></Confirm>
    <p>
      <router-link to="/second">next</router-link>
    </p>
    <button @click="login">登录</button>
    <button @click="getUserList">获取用户列表</button>
    <el-table  :data="userList">
      <el-table-column label="用户编号" align="center" prop="id" />
      <el-table-column label="用户名称" align="center" prop="name" :show-overflow-tooltip="true" />
    </el-table>
  </div>
</template>

<script>
  import Confirm from '@/components/sub/Confirm'
  export default {
    name: "First",
    components: {
      Confirm
    },
    data() {
      return {
        msg: "first vue demo",
        userList: null
      };
    },
    methods: {
      getMessage(val) {
        alert(val);
      },
      getUserList: function() {
        alert("获取数据......");
        this.$axios.get("http://localhost/api/springmvc-shiro-redis/role/list").then(res => {
          var result = res.data;
          this.userList=res.data;
        });
      },
      login: function() {
        this.$axios.post("http://localhost/api/springmvc-shiro-redis/login",{
            username:'admin',
            password:'123456'
        }).then(res => {
          var result = res.data;
        });
      }
    }
  };
</script>

<style>
</style>
